import { createApp } from 'vue'
import App from './App.vue'
import router from '@/router/index.ts'
import './assets/main.scss'
// npm i pinia-plugin-persistedstate    -pinia的持久化插件
import persist from 'pinia-plugin-persistedstate'
import {createPinia} from 'pinia'
import {tokenStore} from '@/store/token'

import Vue3DraggableResizable from 'vue3-draggable-resizable'
//default styles
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'


// import VueAMap from 'vue-amap';
import DataVVue3 from '@kjgl77/datav-vue3'
let pinia=createPinia();
pinia.use(persist) //让pinia 使用持久化插件



let app=createApp(App);
app.use(pinia)
app.use(Vue3DraggableResizable)
app.use(DataVVue3)

let tStore=tokenStore();
// main.ts中的路由守卫
router.beforeEach((to,from,next)=>{
      if(!tStore.token&&to.path!='/login'){
        
         next("/login") 
      }
      next();
})
app.use(router)
app.mount('#app')
